-- 主线程
function main()
    MainBianLiang() -- 普通变量
    downLua() -- 下载脚本
    MultiThread() -- 多线程脚本
    requireLua() -- 普通脚本
end
-- 下载Lua
function downLua()
    delFile(userPath() .. "/lua/ReXue.lua")
    mSleep(200)
    lug_ReXue = "https://gitee.com/xinqinew_admin/re-xue/raw/master/ReXue.lua"
    code, msg = ts.tsDownload(userPath() .. "/lua/ReXue.lua", lug_ReXue, {
        ["tstab"] = 1,
        ["mode"] = true
    })
    mSleep(200)
    if code == 200 then
        toast("下载ReXue成功：" .. msg)
    else
        toast("下载ReXue失败：" .. msg)
    end

    delFile(userPath() .. "/lua/UI_ReXue.lua")
    lug_UI_ReXue = "https://gitee.com/xinqinew_admin/re-xue/raw/master/UI_ReXue.lua"
    code, msg = ts.tsDownload(userPath() .. "/lua/UI_ReXue.lua", lug_UI_ReXue, {
        ["tstab"] = 1,
        ["mode"] = true
    })
    mSleep(200)
    if code == 200 then
        toast("下载UI_ReXue成功：" .. msg)
    else
        toast("下载UI_ReXue失败：" .. msg)
    end

    delFile(userPath() .. "/lua/general.lua")
    lug_general = "https://gitee.com/xinqinew_admin/re-xue/raw/master/general.lua"
    code, msg = ts.tsDownload(userPath() .. "/lua/general.lua", lug_general, {
        ["tstab"] = 1,
        ["mode"] = true
    })
    mSleep(200)
    if code == 200 then
        toast("下载general成功：" .. msg)
    else
        toast("下载general失败：" .. msg)
    end

end
-- 多线程
function MultiThread()

    ThreadBianLiang()
    package.loaded["ReXue"] = nil
    runThread("ReXue")
    mSleep(1000)
    -- runThread("UI_ReXue")
    -- mSleep(1000)
end

-- 装载Lua
function requireLua()
    package.loaded["UI_ReXue"] = nil
    require("UI_ReXue")
end

-- 多线程变量
function ThreadBianLiang()
    var.isRoundUI = 1
    var.pause = 0
    var.isLuaStart = 1
end

-- 主线程变量
function MainBianLiang()
    init(2)
    wScreen, hScreen = getScreenSize()
end
